import { defineStore } from 'pinia'
import { pinia } from '@/store'

interface HomeState {
  homeActive: number
}

export const useHomeStore = defineStore({
  id: 'app-home',
  state: (): HomeState => ({
    homeActive: 0,
  }),
  getters: {
    getHomeActive(): number {
      return this.homeActive
    },
  },
  actions: {
    setHomeActive(url: string) {
      switch (url) {
        case '/home/index':
          this.homeActive = 0
          break
        case '/wealth/index':
          this.homeActive = 1
          break
        case '/pastime/index':
          this.homeActive = 2
          break
        case '/mine/index':
          this.homeActive = 3
          break
      }
    },
  },
})

export function useHomeStoreWithOut() {
  return useHomeStore(pinia)
}
